<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>影片信息 - 前台仪表盘</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
            line-height: 1.6;
        }
        
        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 1rem 0;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .nav {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        
        .logo {
            font-size: 24px;
            font-weight: bold;
        }
        
        .nav-links {
            display: flex;
            gap: 30px;
        }
        
        .nav-links a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            transition: opacity 0.3s;
        }
        
        .nav-links a:hover {
            opacity: 0.8;
        }
        
        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        .section-title {
            color: #333;
            margin-bottom: 30px;
            font-size: 28px;
            font-weight: 600;
        }
        
        .card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }
        
        .card-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px 20px;
            font-weight: 600;
            font-size: 16px;
        }
        
        .card-body {
            padding: 20px;
        }
        
        .btn {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
            text-decoration: none;
            display: inline-block;
            transition: all 0.3s ease;
            text-align: center;
        }
        
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
            color: white;
            text-decoration: none;
        }
        
        .btn-sm {
            padding: 8px 16px;
            font-size: 14px;
        }
        
        .btn-secondary {
            background: #6c757d;
        }
        
        .btn-secondary:hover {
            background: #5a6268;
            box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
        }
        
        .btn-success {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        }
        
        .btn-success:hover {
            box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
        }
        
        .btn-danger {
            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
        }
        
        .btn-danger:hover {
            box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #333;
        }
        
        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 12px;
            border: 2px solid #e1e5e9;
            border-radius: 8px;
            font-size: 14px;
            transition: border-color 0.3s ease;
        }
        
        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #667eea;
        }
        
        .table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            border-radius: 12px;
            overflow: hidden;
        }
        
        .table th,
        .table td {
            padding: 15px;
            text-align: left;
            border-bottom: 1px solid #e1e5e9;
        }
        
        .table th {
            background: #f8f9fa;
            font-weight: 600;
            color: #333;
        }
        
        .table tr:hover {
            background-color: #f8f9fa;
        }
        
        .badge {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 500;
            color: white;
        }
        
        .bg-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .bg-success {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        }
        
        .bg-warning {
            background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
            color: #333;
        }
        
        .bg-danger {
            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
        }
        
        .bg-secondary {
            background: #6c757d;
        }
        
        .text-muted {
            color: #6c757d;
        }
        
        .text-center {
            text-align: center;
        }
        
        .grid-2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }
        
        .grid-3 {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
        }
        
        .alert {
            padding: 15px 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            font-weight: 500;
        }
        
        .alert-success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        
        .alert-danger {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
        
        .alert-warning {
            background: #fff3cd;
            color: #856404;
            border: 1px solid #ffeaa7;
        }
        
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
        }
        
        .modal-content {
            background-color: white;
            margin: 5% auto;
            padding: 0;
            border-radius: 12px;
            width: 90%;
            max-width: 600px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        }
        
        .modal-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 12px 12px 0 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .modal-header h3 {
            margin: 0;
            font-size: 20px;
        }
        
        .modal-body {
            padding: 20px;
        }
        
        .modal-footer {
            padding: 20px;
            border-top: 1px solid #e1e5e9;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }
        
        .close {
            background: none;
            border: none;
            color: white;
            font-size: 24px;
            cursor: pointer;
            padding: 0;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: background-color 0.3s ease;
        }
        
        .close:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }
        
        @media (max-width: 768px) {
            .nav {
                flex-direction: column;
                gap: 15px;
            }
            
            .nav-links {
                gap: 15px;
            }
            
            .grid-2 {
                grid-template-columns: 1fr;
            }
            
            .container {
                padding: 15px;
            }
        }
    </style>
</head>
<body>
    <header class="header">
        <nav class="nav">
            <div class="logo">🎬 前台控制台</div>
            <div class="nav-links">
                <a href="/receptionist/dashboard">控制台</a>
                <a href="/receptionist/movies">影片信息</a>
                <a href="/receptionist/screenings">场次信息</a>
                <a href="/receptionist/sell-ticket">售票功能</a>
                <a href="/receptionist/refund-ticket">退票功能</a>
                <a href="/receptionist/sold-tickets">已售票据</a>
            </div>
            <div class="user-info">
                <span th:text="|前台：${session.user != null ? session.user.username : '未登录'}|">前台</span>
                <a href="/auth/logout" class="btn btn-sm">退出登录</a>
            </div>
        </nav>
    </header>

    <div class="container">
        <h2 class="section-title">📽️ 正在上映的影片 <span class="badge bg-success" th:text="${#lists.size(movies)}">0</span></h2>

        <!-- 搜索框 -->
        <div class="card">
            <div class="card-header">🔍 搜索影片</div>
            <div class="card-body">
                <form action="/receptionist/movies/search" method="get">
                    <div class="grid-3">
                        <div class="form-group">
                            <label>影片名称</label>
                            <input type="text" name="title" placeholder="影片名称" th:value="${searchTitle}">
                        </div>
                        <div class="form-group">
                            <label>导演</label>
                            <input type="text" name="director" placeholder="导演" th:value="${searchDirector}">
                        </div>
                        <div class="form-group">
                            <label>主演</label>
                            <input type="text" name="actors" placeholder="主演" th:value="${searchActors}">
                        </div>
                    </div>
                    <div style="margin-top: 20px; text-align: center;">
                        <button type="submit" class="btn btn-success">🔍 搜索影片</button>
                        <a href="/receptionist/movies" class="btn btn-secondary">📋 显示全部影片</a>
                    </div>
                </form>
            </div>
        </div>

        <!-- 影片列表 -->
        <div th:if="${#lists.isEmpty(movies)}" class="card text-center">
            <div class="card-body" style="padding: 60px 20px;">
                <div style="font-size: 48px; margin-bottom: 20px;">🎬</div>
                <h3 style="color: #6c757d; margin-bottom: 10px;">暂无正在上映的影片</h3>
                <p style="color: #6c757d;">请联系管理员添加影片信息</p>
            </div>
        </div>
        
        <div class="grid-3" th:unless="${#lists.isEmpty(movies)}">
            <div class="card" th:each="movie : ${movies}">
                <div style="position: relative;">
                    <span class="badge" 
                          th:classappend="${movie.rating >= 8 ? 'bg-success' : (movie.rating >= 6 ? 'bg-warning' : 'bg-danger')}"
                          th:text="${movie.rating}"
                          style="position: absolute; top: 10px; right: 10px; z-index: 10;">0.0</span>
                </div>
                <div class="card-body">
                    <h3 style="margin-bottom: 15px; color: #333;" th:text="${movie.title}">影片标题</h3>
                    <div style="margin-bottom: 10px; color: #6c757d; font-size: 14px;">
                        👨‍💼 导演：<span th:text="${movie.director}">导演</span>
                    </div>
                    <div style="margin-bottom: 10px; color: #6c757d; font-size: 14px;">
                        👥 主演：<span th:text="${movie.actors}">主演</span>
                    </div>
                    <div style="margin-bottom: 10px; color: #6c757d; font-size: 14px;">
                        ⏱️ 时长：<span th:text="${movie.duration}">时长</span>分钟
                    </div>
                    <div style="margin-bottom: 15px;">
                        <span class="badge bg-primary">
                            🎬 正在上映
                        </span>
                    </div>
                    <p style="color: #666; line-height: 1.5; margin-bottom: 20px;" th:text="${#strings.abbreviate(movie.synopsis, 100)}">影片简介</p>
                    <button class="btn btn-success" style="width: 100%;" 
                            onclick="viewMovieDetails(this)" 
                            th:data-movie-id="${movie.id}"
                            th:data-title="${movie.title}"
                            th:data-director="${movie.director}"
                            th:data-actors="${movie.actors}"
                            th:data-synopsis="${movie.synopsis}"
                            th:data-duration="${movie.duration}"
                            th:data-rating="${movie.rating}">
                        📋 查看详情
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 影片详情模态框 -->
    <div id="movieDetailModal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>🎬 影片详情</h3>
                <button class="close" onclick="closeMovieDetailModal()">&times;</button>
            </div>
            <div class="modal-body">
                <h4 id="modalTitle" style="margin-bottom: 20px; color: #333;"></h4>
                <div class="grid-2">
                    <div>
                        <div style="margin-bottom: 15px;">
                            <strong style="color: #667eea;">👨‍💼 导演：</strong>
                            <span id="modalDirector"></span>
                        </div>
                        <div style="margin-bottom: 15px;">
                            <strong style="color: #667eea;">👥 主演：</strong>
                            <span id="modalActors"></span>
                        </div>
                        <div style="margin-bottom: 15px;">
                            <strong style="color: #667eea;">⏱️ 时长：</strong>
                            <span id="modalDuration"></span>
                        </div>
                        <div style="margin-bottom: 15px;">
                            <strong style="color: #667eea;">⭐ 评分：</strong>
                            <span id="modalRating" class="badge bg-success"></span>
                        </div>
                    </div>
                    <div>
                        <div>
                            <strong style="color: #667eea;">📝 简介：</strong>
                            <p id="modalSynopsis" style="margin-top: 10px; line-height: 1.6; color: #666;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" onclick="closeMovieDetailModal()">❌ 关闭</button>
            </div>
        </div>
    </div>

    <script>
        let currentMovieId = null;
        
        function viewMovieDetails(button) {
            currentMovieId = button.getAttribute('data-movie-id');
            const title = button.getAttribute('data-title');
            const director = button.getAttribute('data-director');
            const actors = button.getAttribute('data-actors');
            const synopsis = button.getAttribute('data-synopsis');
            const duration = button.getAttribute('data-duration');
            const rating = button.getAttribute('data-rating');
            
            document.getElementById('modalTitle').textContent = title;
            document.getElementById('modalSynopsis').textContent = synopsis;
            document.getElementById('modalDirector').textContent = director;
            document.getElementById('modalActors').textContent = actors;
            document.getElementById('modalDuration').textContent = duration + ' 分钟';
            document.getElementById('modalRating').textContent = rating;
            
            document.getElementById('movieDetailModal').style.display = 'block';
        }
        
        function closeMovieDetailModal() {
            document.getElementById('movieDetailModal').style.display = 'none';
        }
        
        // 点击模态框外部关闭
        window.onclick = function(event) {
            const modal = document.getElementById('movieDetailModal');
            if (event.target === modal) {
                modal.style.display = 'none';
            }
        }
        
        function goToScreenings() {
            if (currentMovieId) {
                window.location.href = '/receptionist/screenings?movieId=' + currentMovieId;
            } else {
                window.location.href = '/receptionist/screenings';
            }
        }
        
        function goToSellTickets() {
            if (currentMovieId) {
                window.location.href = '/receptionist/sell-tickets?movieId=' + currentMovieId;
            } else {
                window.location.href = '/receptionist/sell-tickets';
            }
        }
    </script>
</body>
</html>